home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / appsrcs.zip / APPFINDR.ZIP / DRVSEL.C < prev    next >
C/C++ Source or Header  |  1993-03-26  |  4KB  |  110 lines

  1. #define STRICT
  2. #include <windows.h>
  3. #include <windowsx.h>
  4. #include <ctype.h>
  5. #include <string.h>
  6. #include <stdio.h>
  7. #include <io.h>
  8. #include <stdarg.h>
  9. #include <stdio.h>
  10. #include <direct.h>
  11. #include "appfindr.h"
  12.  
  13. extern char *TempStr, *Directory;
  14.  
  15. /*----------------------------------------------------------------------------*/
  16. /* FUNCTION: AppDlgProc(HWND, unsigned, WORD, LONG)                           */
  17. /*                                                                            */
  18. /* PURPOSE:  Processes Dialog Box Messages                                    */
  19. /*----------------------------------------------------------------------------*/
  20. BOOL WINAPI AppDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  21.     {
  22.     static BOOL ListBoxFocus = FALSE;
  23.  
  24.     switch(message)
  25.         {
  26.         case WM_INITDIALOG:
  27.             strcpy(TempStr, Directory);
  28.             UpdateListBox(hDlg);
  29.             SetFocus(GetDlgItem(hDlg, IDC_LISTBOX));
  30.         return TRUE;
  31.             break;
  32.  
  33.         case WM_COMMAND:
  34.             switch(wParam)
  35.                 {
  36.                 case IDC_LISTBOX:
  37.                     switch(HIWORD(lParam))
  38.                         {
  39.                         case LBN_SETFOCUS:
  40.                             ListBoxFocus = TRUE;
  41.                             SendDlgItemMessage(hDlg, IDC_LISTBOX, LB_SETCURSEL,
  42.                               GetListBoxIndex(hDlg), 0L);
  43.                             return TRUE;
  44.  
  45.                         case LBN_KILLFOCUS:
  46.                             ListBoxFocus = FALSE;
  47.                             SendDlgItemMessage(hDlg, IDC_LISTBOX, LB_SETCURSEL,
  48.                               -1, 0L);
  49.                             return TRUE;
  50.  
  51.                         case LBN_DBLCLK:
  52. DoubleClick:                DlgDirSelect(hDlg, TempStr, IDC_LISTBOX);
  53.                             UpdateListBox(hDlg);
  54.                             return (TRUE);
  55.                             break;
  56.  
  57.                         } /* end IDC_LISTBOX switch */
  58.                     break;
  59.  
  60.                 case IDOK:
  61.                     if(ListBoxFocus)
  62.                         goto DoubleClick;
  63.  
  64.                     GetDlgItemText(hDlg, IDC_PATH, Directory, sizeof(Directory));
  65.             EndDialog(hDlg,TRUE);
  66.             return (TRUE);
  67.                     break;
  68.  
  69.                 case IDCANCEL:
  70.                     EndDialog(hDlg,FALSE);
  71.                     return (TRUE);
  72.                     break;
  73.  
  74.                 default:
  75.                     return (FALSE);
  76.                 } /* end WM_COMMAND SWITCH */
  77.         default:
  78.             return (FALSE);
  79.         }
  80.     }
  81.  
  82. /*----------------------------------------------------------------------------*/
  83. /* FUNCTION: UpdateListBox(HWND hDlg)                                         */
  84. /*                                                                            */
  85. /* PURPOSE:  Helper function for dialog window proc                           */
  86. /*----------------------------------------------------------------------------*/
  87. void UpdateListBox(HWND hDlg)
  88.     {
  89.     SetDlgItemText(hDlg, IDC_PATH, TempStr);
  90.     DlgDirList(hDlg, TempStr, IDC_LISTBOX, IDC_PATH, 0xC000);
  91.     SendDlgItemMessage(hDlg, IDC_LISTBOX, LB_SETCURSEL,
  92.       GetListBoxIndex(hDlg), 0L);
  93.     }
  94.  
  95. /*----------------------------------------------------------------------------*/
  96. /* FUNCTION: GetListBoxIndex(HWND hDlg)                                       */
  97. /*                                                                            */
  98. /* PURPOSE:  Helper function for dialog window proc                           */
  99. /*----------------------------------------------------------------------------*/
  100. WORD GetListBoxIndex(HWND hDlg)
  101.     {
  102.     WORD rtn;
  103.  
  104.     rtn = (WORD)SendDlgItemMessage(hDlg, IDC_LISTBOX, LB_GETCURSEL, 0, 0L);
  105.     if(rtn == LB_ERR)
  106.         return 0;
  107.     else
  108.         return rtn;
  109.     }
  110.